From: Arianna Avanzini Date: Sat, 30 Aug 2014 16:29:44 +0000 (+0200) Subject: tools/libxl: handle the iomem parameter with the memory_mapping hcall X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~4485 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=c428c9f162895cb3473fab26d23ffbf41a6f293d;p=xen.git tools/libxl: handle the iomem parameter with the memory_mapping hcall Currently, the configuration-parsing code concerning the handling of the iomem parameter only invokes the XEN_DOMCTL_iomem_permission hypercall. This commit lets the XEN_DOMCTL_memory_mapping hypercall be invoked after XEN_DOMCTL_iomem_permission when the iomem parameter is parsed from a domU configuration file, so that the address range can be mapped to the address space of the domU. The hypercall is invoked only in case of domains using an auto-translated physmap. Signed-off-by: Arianna Avanzini Acked-by: Ian Campbell Acked-by: Julien Grall Cc: Dario Faggioli Cc: Paolo Valente Cc: Stefano Stabellini Cc: Jan Beulich Cc: Keir Fraser Cc: Tim Deegan Cc: Ian Jackson Cc: Andrew Cooper Cc: Eric Trudeau Cc: Viktor Kleinik Cc: Andrii Tseglytskyi --- diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index c67ac9af6c..1eba39379a 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -1960,6 +1960,16 @@ int xc_domain_memory_mapping( uint32_t add_mapping) { DECLARE_DOMCTL; + xc_dominfo_t info; + + if ( xc_domain_getinfo(xch, domid, 1, &info) != 1 || + info.domid != domid ) + { + PERROR("Could not get info for domain"); + return -EINVAL; + } + if ( !xc_core_arch_auto_translated_physmap(&info) ) + return 0; domctl.cmd = XEN_DOMCTL_memory_mapping; domctl.domain = domid; diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index bc44ef5eda..ee328e9d0d 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1180,6 +1180,17 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, "failed give dom%d access to iomem range %"PRIx64"-%"PRIx64, domid, io->start, io->start + io->number - 1); ret = ERROR_FAIL; + continue; + } + ret = xc_domain_memory_mapping(CTX->xch, domid, + io->gfn, io->start, + io->number, 1); + if (ret < 0) { + LOGE(ERROR, + "failed to map to dom%d iomem range %"PRIx64"-%"PRIx64 + " to guest address %"PRIx64, + domid, io->start, io->start + io->number - 1, io->gfn); + ret = ERROR_FAIL; } }